public class Node{
    public int value;
    public Node left;
    public Node right;
    public Node(int data){
        this.value=data;
    }
}

public void preOrderUnRecur(Node head){
    if(head==null)return;
    if(head!=null){
        Stack<Node> stack=new Stack<>();
        stack.push(head);
        while(stack.isEmpty()){
            head=stack.pop();
            System.out.print(head.value+" ");
            if(head.left!=null){
                stack.push(head.left);
            }
            if(head.right!=null){
                stack.push(head.right);
            }
        }
    }
    System.out.println();
}




public void preOrderUnRecur(Node head){
    if(head!=null){
        Stack<Node> stack=new Stack<>();
        stack.push(head);
        while(!stack.isEmpty()){
            head=stack.pop();
            System.out.print(head.value+" ");
            if(head.left!=null){
                stack.push(head.right);
            }
            if(head.right!=null){
                stack.push(head.left);
            }
        }
    }
    System.out.println();
}